|
|
|
|
|
|
|
Manipulating the Registry |
|
|
|
|
|
|
|
|
You can use Windows API calls to manipulate the System Registry, or you can use built-in Visual Basic functions. Using API calls, youre allowed to manipulate any area of the Registry. However, youre only allowed to manipulate one area of the Registry when you use the built-in Visual Basic functions. Lets look at using the Windows API calls first. |
|
|
|
|
|
|
|
|
Using Windows API calls, lets modify the only area in the Registry that can be modified by the built-in Visual Basic functions. This area is in HKEY_CURRENT_USER\Software\VB and VBA Program Settings. Here, youll create one or many keys, as needed for each application. For example, the following code shows you a key called \UserStorage. Under this key is another key called \Database, with a key called Path and a value of d:\train\database: |
|
|
|
 |
|
|
|
|
HKEY_CURRENT_USER
\Software
\VB and VBA Program Settings
\UserStorage
\Database
\Path=d:\train\database |
|
|
|
|
|
|
|
|
Examples Filename: Registry.frm |
|
|
|
|
|
|
|
|
If you click the Get command button shown in Figure 29.3, youll run code that retrieves information from this area of the Registry. Of course, if you havent saved anything to this key in the Registry, you wont receive any values back. When you run this example for the first time, click the Save command button to save data to the key first. |
|
|
|
|
|
|
|
|
Figure 29.3
An application that reads from and writes to the Registry. |
|
|
|
|
|